package com.braveman.im.ui.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import com.braveman.im.R;
import com.braveman.im.bean.DataSearchBean;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.qmuiteam.qmui.widget.QMUIRadiusImageView;


import java.util.List;


public class HomeSearchAdapter extends BaseSectionQuickAdapter<DataSearchBean, BaseViewHolder> {
    private QMUIRadiusImageView qmuiRadiusImageView;

    public HomeSearchAdapter(int layoutResId, int sectionHeadResId, List data) {
        super(layoutResId, sectionHeadResId, data);
    }

    @Override
    protected void convertHead(BaseViewHolder helper, final DataSearchBean item) {
        helper.setText(R.id.tv_item_home_head, item.header).setGone(R.id.tv_line, item.isShow);

    }


    @Override
    protected void convert(BaseViewHolder helper, DataSearchBean item) {
        qmuiRadiusImageView = helper.getView(R.id.iv_item_company_check_head_icon);
        qmuiRadiusImageView.setCircle(false);
        String name = !TextUtils.isEmpty(item.groupName) ? item.groupName : item.friendName;
        String icon = !TextUtils.isEmpty(item.groupIcon) ? item.groupIcon : item.friendAvatar;
        Glide.with(mContext).load(icon).into(qmuiRadiusImageView);
        helper.setText(R.id.iv_item_company_check_info, name).addOnClickListener(R.id.rl_see_more).setGone(R.id.rl_see_more, item.isFoot);
    }
}

